From 2155550fa36a3bc3c8f66e0926530123b4018cd4 Mon Sep 17 00:00:00 2001 From: Armand Philippot Date: Mon, 16 May 2022 12:46:38 +0200 Subject: refactor: use custom hook for breadcrumb items and schema --- src/pages/thematique/[slug].tsx | 22 ++++++---------------- 1 file changed, 6 insertions(+), 16 deletions(-) (limited to 'src/pages/thematique/[slug].tsx') diff --git a/src/pages/thematique/[slug].tsx b/src/pages/thematique/[slug].tsx index dd7e80d..13ef0da 100644 --- a/src/pages/thematique/[slug].tsx +++ b/src/pages/thematique/[slug].tsx @@ -1,5 +1,4 @@ import Heading from '@components/atoms/headings/heading'; -import { type BreadcrumbItem } from '@components/molecules/nav/breadcrumb'; import PostsList, { type Post } from '@components/organisms/layout/posts-list'; import LinksListWidget from '@components/organisms/widgets/links-list-widget'; import PageLayout, { @@ -18,6 +17,7 @@ import { getPageLinkFromRawData, getPostMeta, } from '@utils/helpers/pages'; +import useBreadcrumb from '@utils/hooks/use-breadcrumb'; import useSettings from '@utils/hooks/use-settings'; import { GetStaticPaths, GetStaticProps, NextPage } from 'next'; import Head from 'next/head'; @@ -40,21 +40,10 @@ const ThematicPage: NextPage = ({ const { content, intro, meta, slug, title } = currentThematic; const { articles, dates, seo, topics } = meta; const intl = useIntl(); - const homeLabel = intl.formatMessage({ - defaultMessage: 'Home', - description: 'Breadcrumb: home label', - id: 'j5k9Fe', + const { items: breadcrumbItems, schema: breadcrumbSchema } = useBreadcrumb({ + title, + url: `/thematique/${slug}`, }); - const blogLabel = intl.formatMessage({ - defaultMessage: 'Blog', - description: 'Breadcrumb: blog label', - id: 'Es52wh', - }); - const breadcrumb: BreadcrumbItem[] = [ - { id: 'home', name: homeLabel, url: '/' }, - { id: 'blog', name: blogLabel, url: '/blog' }, - { id: 'thematic', name: title, url: `/thematique/${slug}` }, - ]; const headerMeta: PageLayoutProps['headerMeta'] = { publication: { date: dates.publication }, @@ -152,7 +141,8 @@ const ThematicPage: NextPage = ({ dangerouslySetInnerHTML={{ __html: JSON.stringify(schemaJsonLd) }} />